package com.liam.es.controller;

import com.liam.es.entity.es.Question;
import com.liam.es.repository.es.QuestionRepository;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

@RestController
@RequestMapping("/question")
public class QuestionController {

    @Autowired
    RestHighLevelClient elasticsearchClient;
    @Autowired
    QuestionRepository questionRepository;

    @RequestMapping("/find/{id}")
    public Question getBookById(@PathVariable String id){

        return null;
    }

    @RequestMapping("/save")
    @ResponseBody
    public void Save(){
        Question question = new Question();
        question.setQuestion("电视剧《斗罗大陆》中谁给了夜火村村长能使武魂变异的药？");
        question.setAnswer("不乐");
        question.setOptions("素云涛;胡列娜;不乐");

        questionRepository.save(question);
    }
}
